import React, { Component } from 'react';
import {Menu, Icon, Layout,  } from 'antd';
import { Link } from "react-router-dom";

// 引入的组件（antd）
const {Sider} = Layout;
const SubMenu = Menu.SubMenu;
// 样式文件。 头部的logo地方
let logoStyle = {
	height: '32px',
	background: 'rgba(255,255,255,.2)',
	margin: '16px'
}

class LeftLayout extends Component {
    // 保存侧边栏打开关闭的状态
	state = {
		collapsed : false,
    };
    // 侧边栏打开关闭的回调函数
	onCollapse = (collapsed) => {
		console.log(collapsed);
		this.setState({
			collapsed
		});
	}

    render() {
        return (
            <Sider
            collapsible
            collapsed={this.state.collapsed}
            onCollapse={this.onCollapse}
        >
            <div className="logo" style= {logoStyle}/>
            <Menu theme="dark" defaultSelectedKeys={['1']} mode="inline">
                <SubMenu
                    key="sub0"
                    title={<span><Icon type="user" /><span>Guide</span></span>}
                >
                    <Menu.Item key="1">	<Link to='/Guide'>首页</Link></Menu.Item>
                </SubMenu>
                <SubMenu
                    key="sub1"
                    title={<span><Icon type="user" /><span>User</span></span>}
                >
                    <Menu.Item key="2">	<Link to='/Permission'>权限</Link></Menu.Item>
                    <Menu.Item key="3"><Link to='/User'>用户</Link></Menu.Item>
                    <Menu.Item key="5">管理员</Menu.Item>
                    <Menu.Item key="6">封号</Menu.Item>
                </SubMenu>
                <SubMenu
                    key="sub2"
                    title={<span><Icon type="team" /><span>func</span></span>}
                >
                    <Menu.Item key="7">失物招领</Menu.Item>
                    <Menu.Item key="8">表白墙</Menu.Item>
                </SubMenu>
                <Menu.Item key="9">
                    <Icon type="file" />
                    <span>File</span>
                </Menu.Item>
            </Menu>
        </Sider>
        );
    }
}

export default LeftLayout;